<?php
/**
 * Date: 2019/4/16 17:05
 */

namespace App\Tools;

use Symfony\Component\VarDumper\VarDumper;
    /**
 * Definition for a singly-linked list.
 * class ListNode {
 *     public $val = 0;
 *     public $next = null;
 *     function __construct($val) { $this->val = $val; }
 * }
 */
class Solution {

    /**
     * @author: tangjianing(990921093@qq.com)
     * @date: 2019/4/16 18:33
     * @param ListNode $list
     * @param ListNode $list2
     * @return LinkedList
     */
    public function addTwoNumbers(ListNode $list, ListNode $list2) {
        $num = '';
        $num2 = '';
        while ($list !== NULL) {
            $num.=$list->val;
            $list = $list->next;
        }
        while ($list2 !== NULL) {
            $num2.=$list2->val;
            $list2 = $list2->next;
        }
        $num = (int)strrev($num);
        $num2 = (int)strrev($num2);
        $num3 = $num+$num2;
        $arr = array_reverse(str_split($num3));



    }

    public function insert(string $data = NULL) {
        $newNode = new ListNode($data);
        while ($newNode->next !== NULL) {
            $newNode = $newNode->next;
        }
        $newNode->next = $newNode;
        return true;
    }

}

